#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int N = 0; //100005

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int x,y;
	cin >> x >> y;
	int cnt = 0;
	if(x==y) cnt--;
	int chen = x*y;//最大公因数*最小公倍数=求这两个量的数的乘积
	for(int i=1;i*i<=chen;i++)
	{
		if(chen%i==0 && gcd(i,chen/i)==x && lcm(i,chen/i)==y) cnt+=2;
	}
	cout << cnt;
	return 0;
}
